package com.cat.model.web.action.base;

import com.alonew.core.commons.page.AjaxObject;
import com.alonew.core.commons.page.Page;

public abstract class AdminAction extends BaseAction {

	private static final long serialVersionUID = -3721271320756045097L;
	
	private String parentTabId;
	private String curTabId;
	private String functionCode;
	private Page pageInfo;

	/**
	 * 获取分页参数
	 * 
	 * @return
	 */
	protected Page fetchPageParams() {
		Page page = new Page();
		String pageNum = request.getParameter("pageNum"); // 页码
		String numPerPage = request.getParameter("numPerPage"); // 每页显示数
		if (null != pageNum && null != numPerPage) {
			page.setPageNum(Integer.parseInt(pageNum));
			page.setNumPerPage(Integer.parseInt(numPerPage));
		}
		pageInfo = page;
		return page;
	}
	
	public void okAlert(String msg){
		this.print(AjaxObject.newOk(msg).setCallbackType("").toString());
	}
	
	public void parentAlert(boolean success, String msg){
		this.printHTML("<script>parent.callback(" + success + ", '" + msg + "')</script>");
	}

	public String getParentTabId() {
		return parentTabId;
	}

	public void setParentTabId(String parentTabId) {
		this.parentTabId = parentTabId;
	}

	public String getCurTabId() {
		return curTabId;
	}

	public void setCurTabId(String curTabId) {
		this.curTabId = curTabId;
	}

	public String getFunctionCode() {
		return functionCode;
	}

	public void setFunctionCode(String functionCode) {
		this.functionCode = functionCode;
	}

	public Page getPageInfo() {
		return pageInfo;
	}

	public void setPageInfo(Page pageInfo) {
		this.pageInfo = pageInfo;
	}

}
